void main() {
  final p = new Person('张三', 18);
  Person p1 = new Person.person1('李四');
  print(p.name);
  print(p.age);
  print(p1.name);
  print(p1.age);
}

class Person {
  String? name;
  int? age;

  // 构造函数
  // Person(String name, int age) {
  //   this.name = name;
  //   this.age = age;
  // }

  // 简写
  Person(this.name, this.age);

  // 命名构造函数并自定义参数
  Person.person1(this.name);

  void eat() {
    print('吃');
  }
}
